<template>
  <div>
    <el-form :model="queryParam" :inline=true style="display: flex">
      <el-form-item label="编码">
        <el-input v-model="queryParam.code" style="width:160px"/>
      </el-form-item>
      <el-form-item label="名称">
        <el-input v-model="queryParam.name" style="width:160px"/>
      </el-form-item>
      <el-form-item label="日期">
        <el-input v-model="queryParam.date" style="width:160px"/>
      </el-form-item>
      <el-form-item label="时间">
        <el-input v-model="queryParam.time" style="width:160px"/>
      </el-form-item>
      <el-form-item label="策略名称">
        <el-input v-model="queryParam.strategy" style="width:160px"/>
      </el-form-item>
      <el-form-item label="行业">
        <el-input v-model="queryParam.industryName" style="width:160px"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="queryPage">搜索</el-button>
      </el-form-item>
    </el-form>

    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column prop="id" label="序号" width="80"></el-table-column>
      <el-table-column prop="code" label="编码" width="80"></el-table-column>
      <el-table-column prop="name" label="名称" width="100"></el-table-column>
      <el-table-column prop="date" label="日期" width="100"></el-table-column>
      <el-table-column prop="time" label="时间" width="100"></el-table-column>
      <el-table-column prop="industryName" label="行业" width="100"></el-table-column>
      <el-table-column prop="lastRate" label="最新价"></el-table-column>
      <el-table-column prop="lastPrice" label="累计涨幅"></el-table-column>
      <el-table-column prop="strategy" label="策略名称"></el-table-column>
      <el-table-column prop="d3Rate" label="涨幅3d"></el-table-column>
      <el-table-column prop="d5Rate" label="涨幅5d"></el-table-column>
      <el-table-column prop="d10Rate" label="涨幅10d"></el-table-column>
      <el-table-column prop="d20Rate" label="涨幅20d"></el-table-column>
      <el-table-column prop="d40Rate" label="涨幅40d"></el-table-column>
    </el-table>

    <pagination
      v-show="pageTotal>0"
      :total="pageTotal"
      :page.sync="queryParam.pageNum"
      :limit.sync="queryParam.pageSize"
      @pagination="queryPage"
    />
  </div>
</template>

<script>

export default {
  data () {
    return {
      // 查询参数
      pageTotal: 0,
      queryParam: {
        code: '',
        name: '',
        date: '',
        time: '',
        strategy: '',
        industryName: '',
        pageNum: 1,
        pageSize: 10
      },
      tableData: []
    }
  },
  mounted () {
    this.pageList()
  },
  methods: {
    queryPage () {
      var _this = this
      _this.pageList()
    },
    pageList () {
      var _this = this
      this.$api.strategyResultPageList(_this.queryParam).then(res => {
        if (res.code === '00000') {
          _this.tableData = res.data.pageList
          _this.pageTotal = res.data.pageTotal
        } else {
          _this.$message(res.msg)
        }
      }).catch(e => {
        console.log('接口访问异常!')
      })
    }
  }
}
</script>
